package group.igfd.manager.biz.controller;

import java.util.Arrays;
import java.util.Date;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import group.igfd.manager.biz.entity.CouponActivityDetailEntity;
import group.igfd.manager.biz.service.CouponActivityDetailService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 活动明细表
 *
 * @author knight
 * @email sunlightcs@gmail.com
 * @date 2018-11-28 11:15:25
 */
@RestController
@RequestMapping("biz/couponActivityDetail")
public class CouponActivityDetailController {
    @Autowired
    private CouponActivityDetailService couponActivityDetailService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("biz:couponActivity:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = couponActivityDetailService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("biz:couponActivity:info")
    public R info(@PathVariable("id") Integer id){
			CouponActivityDetailEntity couponActivityDetail = couponActivityDetailService.selectById(id);

        return R.ok().put("couponActivityDetail", couponActivityDetail);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("biz:couponActivity:save")
    public R save(@RequestBody CouponActivityDetailEntity couponActivityDetail){

        couponActivityDetail.setCreatedAt(new Date());
        couponActivityDetail.setUpdatedAt(new Date());
        couponActivityDetailService.insert(couponActivityDetail);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("biz:couponActivity:update")
    public R update(@RequestBody CouponActivityDetailEntity couponActivityDetail){
        couponActivityDetail.setUpdatedAt(new Date());
        couponActivityDetailService.updateById(couponActivityDetail);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("biz:couponActivity:delete")
    public R delete(@RequestBody Integer[] ids){
			couponActivityDetailService.deleteBatchIds(Arrays.asList(ids));

        return R.ok();
    }

}
